import 'package:flutter/material.dart';
import 'package:listview/models/list_item.dart';
import 'package:listview/screens/item_detail_screen.dart';
import 'screens/icon_list_screen.dart';
import 'package:provider/provider.dart';
import 'providers/list_provider.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
        // 创建 ListProvider 实例
        create: (context) =>  ListProvider(),
    child: MaterialApp(
    title: "Flutter demo of list with Provider",
    theme: ThemeData
    (primarySwatch: Colors.blue,
    scaffoldBackgroundColor: Colors.grey[100],
    appBarTheme: const AppBarTheme(
    elevation: 1,
    centerTitle: true ,
    ),

    ) ,
    initialRoute:'/',
    routes: {
      '/':(context)=>IconListScreen(),
    '/detail':(context){
        final item = ModalRoute.of(context)!.settings.arguments as ListItem;
        return ItemDetailScreen(item: item);
    }
    },
      debugShowCheckedModeBanner: false,
    ),
    );

  }
}
